//
// GNS_SendMsgWnd.cpp
// GameHall
//
// Created by mr.l on 16/2/2.
//
//

#include "GNS_SendGoldWnd.h"


#define winsize Director::getInstance()->getVisibleSize()

enum{
	BTN_CLOSE,
	BTN_SEND,
};

GNS_SendGoldWnd::GNS_SendGoldWnd()
{

}

GNS_SendGoldWnd::~GNS_SendGoldWnd()
{

}

GNS_SendGoldWnd* GNS_SendGoldWnd::createLayer(std::string CsbName)
{
	auto pLayer = GNS_SendGoldWnd::create();
	auto pScene = Director::getInstance()->getRunningScene();
	if (!pScene)
		return 0;
	pLayer->SetNodeName(CsbName);
	return pLayer;
}

bool GNS_SendGoldWnd::init()
{
	if (!GNS_YJFLayer::init())
	{
		return false;
	}
	return true;
}
void GNS_SendGoldWnd::SetNodeName(std::string CsbName)
{
	m_RootNode = Loadcsb(CsbName);
	addChild(m_RootNode, 11);

	m_submitBT = static_cast<Button*>(m_RootNode->getChildByName("Button_1"));
	m_cancleBT = static_cast<Button*>(m_RootNode->getChildByName("Button_2"));
// 	btnQueding->setTag(BTN_SEND);
// 	btnQueding->addTouchEventListener(CC_CALLBACK_2(GNS_SendGoldWnd::BtnCallBack, this));

	m_imputText = static_cast<TextField*>(m_RootNode->getChildByName("TextField_1"));

	m_imputgoldNum = static_cast<TextField*>(m_RootNode->getChildByName("TextField_2"));
}

long long GNS_SendGoldWnd::getImputNum()
{
	long long num = 0;
	string numstr = m_imputgoldNum->getString();
	if (CCGnsOften::isNumber(numstr))
	{
		num = -1;
	}
	num = atoi(numstr.c_str());
	return num;
}

string GNS_SendGoldWnd::getInputString()
{
	return m_imputText->getString();
}

void GNS_SendGoldWnd::BtnCallBack(cocos2d::Ref *pSender, ui::Widget::TouchEventType type){
	if (type == ui::Widget::TouchEventType::ENDED) {
		auto pButton = (Button*)pSender;
		int BtnTag = pButton->getTag();
		switch (BtnTag) {
		case BTN_CLOSE:
		{
				Show(false);
				break;
		}
		case BTN_SEND:
		{
				Show(false);
				break;
		}
		default:
			break;
		}
	}
}
